package readini

type ListenFunc func(string)

type Listener interface {
	listen(inifile string)
}

func (listenFunc ListenFunc) listen(filename string) {
	listenFunc(filename)
}

//Watch函数，参数为文件名和监听者，读取ini配置文件并监听配置变化
func Watch(filename string, listener Listener) (*Configuration, error) {
	cfg, err := Load(filename)
	if err != nil {
		return nil, err
	}
	go listener.listen(filename)
	return cfg, nil
}
